package com.easyjop.Controller;

import com.easyjop.annotation.GlobalInterceptor;
import com.easyjop.annotation.VerifyParam;
import com.easyjop.entity.vo.ResponseVO;
import com.easyjop.mappers.ACommonMapper;
import com.easyjop.service.AppUserCollectService;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController("appUserCollectController")
@RequestMapping("/appUserCollect")
public class AppUserCollectController extends ABaseController{
    @Resource
    private AppUserCollectService appUserCollectService;
    @Resource
    private ACommonMapper aCommonMapper;
    @RequestMapping("/addCollect")
    @GlobalInterceptor()
    public ResponseVO addCollect(@RequestHeader(value = "token", required = false) String token,
                                 @VerifyParam(required = true) String objectId,
                                 @VerifyParam(required = true) Integer collectType) {
        appUserCollectService.saveCollect(getAppUserLoginInfoFromToken(token).getUserId(), objectId, collectType);
        return getSuccessResponseVO(null);
    }
    @RequestMapping("/cancelCollect")
    @GlobalInterceptor()
    public ResponseVO cancelCollect(@RequestHeader(value = "token", required = false) String token,
                                    @VerifyParam(required = true) String objectId,
                                    @VerifyParam(required = true) Integer collectType) {
        appUserCollectService.deleteAppUserCollectByUserIdAndObjectIdAndCollectType(getAppUserLoginInfoFromToken(token).getUserId(), objectId, collectType);

        return getSuccessResponseVO(null);
    }
}
